package com.smxy.mall.controller;

import com.smxy.mall.common.Response;
import com.smxy.mall.model.request.CategoryReq;
import com.smxy.mall.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "商品分类")
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    @ApiOperation("全部分类")
    @GetMapping("/list")
    public Object list(@RequestParam("shopId")Integer shopId){
        return Response.success(categoryService.list(shopId));
    };

    @ApiOperation("添加编辑分类")
    @PostMapping("/save")
    public Object save(CategoryReq categoryReq){
        return Response.success(categoryService.save(categoryReq));
    }
}
